<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="table/css/bootstrap.min.css">
    <link rel="stylesheet" href="table/css/bootstrap-table.min.css">
</head>
<body>
<div class="container">
    <p>
    <div class="form-group">
        <form action="addPermission.do" method="post">
            <div class="input-group">
                <div class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></div>
                <input type="text" class="form-control" name="newPemissonName" placeholder="新权限名" style="width: 20%">
                <button class="btn btn-danger" type="submit" ><span class="glyphicon glyphicon-plus"></span>添加</button>
            </div>
        </form>
    </div>
    </p>
    <table id="table"
           data-toggle="table"
           data-url="data/data1.json"
           data-show-columns="true"
           data-search="true"
           data-show-refresh="true"
           data-pagination="true"
           data-height="600">
        <thead>
        <tr class="info">
            <th>ID</th>
            <th>权限名</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach var="p" items="${allPermissions}" >
            <tr >
                <td class="success">${p.permissionId}</td>
                <td>${p.permissionName}</td>
                <td>
                    <a target="mainFrame" onclick="delete_confirm();">
                        <button class="btn btn-danger" type="button" ><span class="glyphicon glyphicon-remove-circle">删除</span></button>
                    </a>
                    <a target="mainFrame">
                        <button class="btn btn-success" type="button"><span class="glyphicon glyphicon-pencil">修改</span></button>
                    </a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<script src="table/js/jquery.min.js"></script>
<script src="table/js/bootstrap.min.js"></script>
<!--<script src="assets/bootstrap2.3/js/bootstrap.min.js"></script>-->
<script src="table/js/tableExport.js"></script>
<script src="table/js/jquery.base64.js"></script>
<script src="table/js/bootstrap-table.js"></script>
<script src="table/js/bootstrap-table-export.js"></script>
<script>
    $(function () {
        $('#build').click(build);//.trigger('click');
        $('#cells, #rows').keyup(function (e) {
            if (e.keyCode === 13) {
                build();
            }
        });
    });

    function build() {
        var cells = $('#cells').val(),
            rows = $('#rows').val(),
            i, j, row,
            columns = [],
            data = [];

        for (i = 0; i < cells; i++) {
            columns.push({
                field: 'field' + i,
                title: 'Cell' + i
            });
        }
        for (i = 0; i < rows; i++) {
            row = {};
            for (j = 0; j < cells; j++) {
                row['field' + j] = 'Row-' + i + '-' + j;
            }
            data.push(row);
        }
        $('#table').bootstrapTable('destroy').bootstrapTable({
            columns: columns,
            data: data
        });
    }

    function delete_confirm() {
        event.returnValue = confirm("删除是不可恢复的，你确认要删除吗？");
    }
    var count =0;
</script>
</body>
</html>
